package com.denlaku.longan.controller.impl;

import com.denlaku.longan.anno.VarBy;
import com.denlaku.longan.controller.AuditLogController;
import com.denlaku.longan.core.Current;
import com.denlaku.longan.http.Resp;
import com.denlaku.longan.http.Return;
import com.denlaku.longan.service.AuditLogService;
import com.denlaku.longan.vo.AuditLog;
import com.denlaku.longan.vo.PageBy;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author tianx
 */
@RestController
public class AuditLogControllerImpl implements AuditLogController {
    @Autowired
    private AuditLogService auditLogService;

    @VarBy
    @Override
    public Return<List<AuditLog>> pageList(AuditLog auditLog, PageBy pageBy) {
        auditLog.setTenantId(Current.getTenantId());
        PageHelper.startPage(pageBy.getPage(), pageBy.getSize());
        List<AuditLog> list = auditLogService.list(auditLog);
        return Resp.success(list);
    }
}
